﻿namespace portfolio.Computation
    
    type ParseXYZ =
         {X: int option; Y: int option; Z: int option}

         /// Solve the equation X + Y = Z for provided values
         member p.result =
                match p.X with 
                | Some x -> 
                  match p.Y with
                  | Some y -> 
                    match p.Z with
                    | Some z -> 
                      ("Error: Too many variables have been given values", 0)
                    | None -> 
                      (sprintf "x(%d) + y(%d) = " x y, (x + y))
                  | None ->
                    match p.Z with
                    | Some z -> 
                      (sprintf "z(%d) - x(%d) = " z x, (z - x))
                    | None -> 
                      ("Error: Only X was provided. x = ", (x))
                | None -> 
                  match p.Y with
                  | Some y ->
                    match p.Z with
                    | Some z ->
                      (sprintf "z(%d) - y(%d) = " z y, (z - y))
                    | None ->
                      ("Error: Only Y was provided. y = ", (y))
                  | None ->
                    match p.Z with
                    | Some z ->
                      ("Error: Only Z was provided. z = ", (z))
                    | None ->
                      ("Error: No values were provided.", 0)
